|
|
|
|
|
|
|
ByteSize As Byte
Parity As Byte
StopBits As Byte
XonChar As Byte
XoffChar As Byte
ErrorChar As Byte
EofChar As Byte
EvtChar As Byte
wReservedlAs Integer
End Type |
|
|
|
|
|
|
|
|
For example, if you have a DCB variable named DCB 1 and want to enable parity checking, you would perform the following operation: |
|
|
|
|
|
|
|
|
DCB1.Bits1 = DCB1.Bits1 Or &H02(set bit 1) |
|
|
|
|
|
|
|
|
If you want to turn off parity checking, you would perform this operation: |
|
|
|
|
|
|
|
|
DCB1.Bits1 = DCB1.Bits1 And (Not &H02&) |
|
|
|
|
|
|
|
|
If you want to execute a block of code only if parity is enabled, you would use code like this: |
|
|
|
|
|
|
|
|
If (DCB1.Bits1 And &H2)<>0 Then
' Parity is Enabled
End If |
|
|
|
|
|
|
|
|
Now look for a moment at the field labeled fDtrControl. This field consists of two bits, because the control of the DTR line (a signal used for serial communication) is not a simple Boolean operation. This signal can have three possible modes. It takes two bits to represent three valuesin this case, the values 0 through 2described by the following constants: |
|
|
|
|
|
|
|
|
Public Const DTR_CONTROL_DISABLE = &H0
Public Const DTR_CONTROL_ENABLE = &H1
Public Const DTR_CONTROL_HANDSHAKE = &H2 |
|
|
|
|
|
|
|
|
We know that the fDtrControl bits are located at bits 4 and 5 in the Bits1 variable. How do we extract the value so that we can read it? |
|
|
|
|
|
|
|
|
The first step is to create a mask so that we are only looking at the fDtrControl bits. The mask needs to have bits 4 and 5 set. In binary, this can be seen as 0000000000110000, which is &H30. |
|
|
|
|
|
|
|
|
The bits can be extracted as follows: |
|
|
|
|
|